home *** CD-ROM | disk | FTP | other *** search
/ Delphi 2.0 - Programmer's Utilities Power Pack / Delphi 2.0 Programmer's Utilities Power Pack.iso / s_to_z / tpw32_10 / test.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1996-09-15  |  3.6 KB  |  126 lines

  1. Program Test;
  2. {$F+}
  3.  
  4. { FILE: TEST.PAS
  5.  
  6. Purpose: A test program to test the Win32 API calls in TPW32.PAS
  7.  
  8. History:
  9.    first version
  10.    15 November 1995, Dr A Olowofoyeku
  11. }
  12.  
  13. uses
  14. WinTypes,
  15. WinDos,
  16. Strings,
  17. W32Types,
  18. TPW32,
  19. WinCrt;
  20.  
  21. {/////////////////////////////////////////////////////////}
  22. Function Pad(s:string;const len:byte):string;
  23. {very crude function to pad a string with blanks, up
  24. to length "len"}
  25. var
  26. i,j:byte;
  27. begin
  28.     pad:=s;
  29.     j:=length(s);
  30.     if j>=len then exit;
  31.     for i:=j to pred(len) do s:=s+' ';
  32.     pad:=s;
  33. end;
  34. {/////////////////////////////////////////////////////////}
  35. Procedure MyProc(Var sR:T32SearchRec);far;
  36. {callback procedure for LocateFiles() }
  37. Begin
  38.      Write(Pad(Strpas(sr.Name),12),' = ',pad(strpas(sr.lname),20));
  39.  
  40.      if (sr.attr and fadirectory<>0)
  41.      then write(' [DIR]') else Write(' [',sr.Attr,'] ');
  42.  
  43.      Writeln('  ',sr.Size:8,' bytes');
  44. End;
  45. {/////////////////////////////////////////////////////////}
  46. {/////////////////////////////////////////////////////////}
  47. {/////////////////////////////////////////////////////////}
  48. var
  49. p  : array[0..259] of char;
  50. sR : T32SearchRec;
  51. ms : memorystatus;
  52.  
  53. begin
  54.   {initialise WinCrt screen}
  55.   windoworg.x:=1;
  56.   windoworg.y:=1;
  57.   screensize.x:=120;
  58.   screensize.y:=250;
  59.   windowsize.x:=700;
  60.   windowsize.y:=550;
  61.   Strpcopy(WindowTitle,' Sample Win32 API Program: by The African Chief');
  62.   {see whether Win32 initialised correctly}
  63.   writeln('Win32 Init Status = ',IsWin32OS);
  64.  
  65.  
  66.   {get system memory information}
  67.   Writeln;
  68.   With Ms do begin
  69.      dwlength:=sizeof(memorystatus); {initialise the memory structure}
  70.      GlobalMemoryStatus(ms); {get memory info}
  71.  
  72.      Writeln('System memory in use : ',dwMemoryLoad,'%');
  73.      Writeln('Total physical memory: ',dwTotalPhys,' bytes');
  74.      Writeln('Free  physical memory: ',dwAvailPhys,' bytes');
  75.      Writeln('Total page file      : ',dwTotalPageFile,' bytes');
  76.      Writeln('Free  page file      : ',dwAvailPageFile,' bytes');
  77.      Writeln('Total virtual memory : ',dwTotalVirtual,' bytes');
  78.      Writeln('Free  virtual memory : ',dwAvailVirtual,' bytes');
  79.   end;
  80.  
  81.   {see the drive types }
  82.   Writeln;
  83.   writeln('Drive A: = ',DriveTypes[GetDriveType('A:\')],' drive');
  84.   writeln('Drive B: = ',DriveTypes[GetDriveType('B:\')],' drive');
  85.   writeln('Drive C: = ',DriveTypes[GetDriveType('C:\')],' drive');
  86.   writeln('Drive D: = ',DriveTypes[GetDriveType('D:\')],' drive');
  87.   writeln('Drive E: = ',DriveTypes[GetDriveType('E:\')],' drive');
  88.   writeln('Drive F: = ',DriveTypes[GetDriveType('F:\')],' drive');
  89.   writeln('Drive G: = ',DriveTypes[GetDriveType('G:\')],' drive');
  90.  
  91.   writeln;
  92.  
  93.   {some sundry information}
  94.   Writeln('The current directory is: ',W32ShowDir);
  95.   Writeln('The current drive is    : ',ThisDrive);
  96.   Writeln('\WIN95 is on this drive : ',ExistFileOrDirectory('\WIN95'));
  97.   Writeln('Your Windows is in      : ',GetEnv('windir'));
  98.   Writeln('PATH = ',GetEnv('path'));
  99.  
  100.   {other stuff}
  101.   Writeln;
  102.   while TRUE=TRUE do {endless loop until "q" is entered}
  103.   begin
  104.      {let's find some file names}
  105.      write('Enter a File Spec: ');
  106.      readln(p);
  107.      if Strpas(p)='q' then donewincrt;
  108.  
  109.      { - these lines are the same as a call to LocateFile, below -
  110.      W32FindFirst(p, faAnyFile, sR);
  111.      While DosError=0 do begin
  112.        MyProc(sR);
  113.        W32FindNext(sR);
  114.      end;
  115.      }
  116.      LocateFiles(p, faAnyFile, sR, MyProc);
  117.  
  118.      {let's run a program}
  119.      writeln;
  120.      write('Enter a Program name: ');
  121.      readln(p);
  122.      if (Strpas(p)='q') or (strlen(p)=0)then donewincrt;
  123.      W32WinExec(p,sw_Normal);
  124.   end;
  125. end.
  126.